import request from '@/utils/request'
import BaseUrl from '../BaseUrl'

const systemPath = BaseUrl.getDefaultBaseUrl()
const modulePath = systemPath + '/api-user'
const userRadioPath = systemPath + '/mrm-admin/user'

export const apiUser = {
  // 用户账号列表
  userList: function(query) {
    return request({
      url: modulePath + '/users',
      method: 'get',
      params: query
    })
  },
  bindUserRadio: function(data) {
    return request({
      url: userRadioPath + '/radio/add_or_update_user_channel',
      method: 'post',
      data
    })
  },
  queryUserRadio: function(query) {
    return request({
      url: userRadioPath + '/radio/query_user_channel',
      method: 'get',
      params: query
    })
  },
  queryUserRadioDetail: function(query) {
    return request({
      url: userRadioPath + '/radio/query_user_channel_detail',
      method: 'get',
      params: query
    })
  },
  list: function(query) {
    return request({
      url: modulePath + '/allRoles',
      method: 'get',
      params: query
    })
  },

  create: function(data) {
    return request({
      url: modulePath + '/create',
      method: 'post',
      data
    })
  },

  read: function(data) {
    return request({
      url: modulePath + '/read',
      method: 'get',
      data
    })
  },

  update: function(data) {
    return request({
      url: modulePath + '/update',
      method: 'post',
      data
    })
  },

  delete: function(data) {
    return request({
      url: modulePath + '/delete',
      method: 'post',
      data
    })
  },

  getPermission: function(query) {
    return request({
      url: modulePath + `/menus/${query.roleId}/menus`,
      method: 'get',
      // params: query
    })
  },

  updatePermission: function(data) {
    return request({
      url: modulePath + '/permissions',
      method: 'post',
      data
    })
  },

  roleOptions: function(query) {
    return request({
      url: modulePath + '/options',
      method: 'get',
      params: query
    })
  },
  //所有菜单
  allMenu: function(query) {
    return request({
      url: modulePath + '/menus/findAlls',
      method: 'get',
      params: query
    })
  },
  //当前用户菜单
  currentMenu: function(query) {
    return request({
      url: modulePath + '/menus/current',
      method: 'get',
      params: query
    })
  },
}
